package com.codewsq;


import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class PropertiesTest {

    @Test
    public void test() {
        FileInputStream fis = null;
        try {
            Properties properties = new Properties();
            fis = new FileInputStream("jdbc.properties");
            properties.load(fis);

            String username = properties.getProperty("username");
            String password = properties.getProperty("password");
            Object object = properties.get("object");

            System.out.println(username); // root
            System.out.println(password); // 123456
            System.out.println(object); // hahaha
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                }
            }
        }
    }
}
